package cn.dgut.event;

import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;

@Configuration
@ComponentScan(basePackages = "cn.dgut.aop")
@EnableAspectJAutoProxy
public class UserSend implements ApplicationEventPublisherAware {
    private ApplicationEventPublisherAware applicationEventPublisherAware;
    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
    this.applicationEventPublisherAware=applicationEventPublisherAware;
    }

    @EventListener({UserEvent.class})
    @Async//异步监听事件
    public void UserEventListener(UserEvent event){
        System.out.println("正在处理UserEvent事件："+event.getSource()+":"+event.getName());
    }
}
